#include <iostream>
#include <string>
#include <math.h>

using namespace std;


char board [3][3];

void printboard(){


cout << board[0][0] <<"|" << board[0][1] <<"|" << board[0][2] /*<<"|"*/ <<endl;
cout << board[1][0] <<"|" << board[1][1] <<"|" << board[1][2] /*<<"|"*/ <<endl;
cout << board[2][0] <<"|" << board[2][1] <<"|" << board[2][2] /*<<"|"*/ <<endl;
}

int main() {

	string player1;
	string player2;
	int a;
	int s;
	int x;
	int y;
	
	cout <<"This is a two player game. Player1, please enter your first name: " <<endl;
	cin >>player1;

	cout <<"Hello " <<player1 <<". You will be 'x.' Player 2, now please enter your first name: " <<endl;
	cin >>player2;

	cout <<"Hello " <<player2 <<". You will be 'o'. Now get ready to begin..." <<endl;
	printboard();

	while (1==1){
	if ((board[0][0]=='x' && board[0][1]=='x' && board[0][2]=='x') || (board[1][0]=='x' && board[1][1]=='x' && board[1][2]=='x') || (board[2][0]=='x' && board[2][1]=='x' && board[2][2]=='x') || (board[0][0]=='x' && board[1][0]=='x' && board[2][0]=='x') || (board[0][1]=='x' && board[1][1]=='x' && board[2][1]=='x') || (board[0][2]=='x' && board[1][2]=='x' && board[2][2]=='x') || (board[0][0]=='x' && board[1][1]=='x' && board[2][2]=='x') || (board[2][0]=='x' && board[1][1]=='x' && board[0][2]=='x')){
	cout <<"Congratulations " <<player1 <<"! You have won the game! Better luck next time " <<player2 <<"..." <<endl <<endl;
	system("pause");
	return 0;

	
	} else if ((board[0][0]=='o' && board[0][1]=='o' && board[0][2]=='o') || (board[1][0]=='o' && board[1][1]=='o' && board[1][2]=='o') || (board[2][0]=='o' && board[2][1]=='o' && board[2][2]=='o') || (board[0][0]=='o' && board[1][0]=='o' && board[2][0]=='o') || (board[0][1]=='o' && board[1][1]=='o' && board[2][1]=='o') || (board[0][2]=='o' && board[1][2]=='o' && board[2][2]=='o') || (board[0][0]=='o' && board[1][1]=='o' && board[2][2]=='o') || (board[2][0]=='o' && board[1][1]=='o' && board[0][2]=='o')){
		cout <<"Congratulations " <<player2 <<"! You have won the game! Better luck next time " <<player1 <<"..." <<endl <<endl;
	system("pause");
	return 0;

	} else {
	//printboard();
	cout <<player1 <<", please enter the column, then row: " <<endl;
	cout <<"Column: ";
	cin>>a;
	x=a-1;
	cout <<"Row: ";
	cin>>s;
	y=s-1;
	board[y][x]='x';
	cout <<endl;


	printboard();
	cout <<player2 <<", Please enter the column, then row: " <<endl;
	cout <<"Column: ";
	cin>>a;
	x=a-1;
	cout <<"Row: ";
	cin>>s;
	y=s-1;
	board[y][x]='o';
	cout <<endl;
	printboard();

	}
	
}
	system("pause");
	return 0;
}